<?php
namespace Admin\Controller;
use Think\Controller;
/**
 * 模型管理
 */
class ModelsController extends CommonController {
    /**
     * 模型列表
     */
    public function index(){
         Cookie('__forward__',$_SERVER['REQUEST_URI']);
        $map=array();
        $list = $this->lists("Models", $map);
        $this->assign("_list", $list);
        $this->meta_title = '模型列表';
        $this->display();
   }
   public function add(){
        $this->meta_title = '添加模型';
        $this->display("edit");
   }
   
   
   public function update(){
   
       $res = D('Models')->update();
        if(!$res){
            $this->error(D('Models')->getError());
        }else{
            $this->success($res['id']?'更新成功':'新增成功', Cookie('__forward__'));
        }
   }
   
   public function edit(){
       $id=I("get.id");
       $info=D("models")->where(array("id"=>$id))->find();
       $this->assign("info",$info);
       $this->meta_title = '编辑模型';
       $this->display();
   }
 
}